package com.bianguo.android.functiondemo.view.fragment;

import android.os.Bundle;
import android.app.Fragment;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.bianguo.android.functiondemo.R;
import com.bianguo.android.functiondemo.adapter.MainAdapter;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment extends BaseFragment {

    @BindView(R.id.fragment_home_recycler)
    RecyclerView homeRecycler;

    private LinearLayoutManager layoutManager;
    private ArrayList<String> list;
    private MainAdapter adapter;

    public HomeFragment() {
        // Required empty public constructor
    }

    public static HomeFragment newInstance() {

        Bundle args = new Bundle();

        HomeFragment fragment = new HomeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int layoutId() {
        return R.layout.fragment_home;
    }

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        layoutManager = new LinearLayoutManager(mContext);
        homeRecycler.setLayoutManager(layoutManager);
        list = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            list.add("item --> " + i);
        }
        adapter = new MainAdapter(mContext, list);
        homeRecycler.setAdapter(adapter);
    }
}
